#ifndef MOUSE_H_
#define MOUSE_H_

#include "system.h"
#include "io.h"

class Mouse
{
    public:
    ~Mouse( ){ }
    typedef enum
    {
        LEFT,
        RIGHT,
        N_BUTTON
    }   TYPE_BUTTON;
    typedef enum
    {
        PRESSED,
        RELEASED,
        N_BUTTON_STATUS
    }   TYPE_BUTTON_STATUS;
    
    static const int MOUSE_LEFT = LEFT;
    static const int MOUSE_RIGHT = RIGHT;
    
    static const int BUTTON_PRESSED = PRESSED;
    static const int BUTTON_RELEASED = RELEASED;
    
    static Mouse& create( ){ static Mouse m; return m; }
    void init( );
    bool update( const int& timeout );
    void get_direction( int& x, int& y ) const;
    const TYPE_BUTTON_STATUS get_status( const TYPE_BUTTON& button ) const;
    
    private:
    Mouse( ){ }
    static const int COMMAND_RESET                  = 0xFF;
    static const int COMMAND_RESEND                 = 0xFE;
    static const int COMMAND_SET_DEFAULT            = 0xF6;
    static const int COMMAND_DISABLE_DATA_REPORTING = 0xF5;
    static const int COMMAND_ENABLE_DATA_REPORTING  = 0xF4;
    static const int COMMAND_SET_SAMPLE_RATE        = 0xF3;
    static const int COMMAND_GET_DEVICE_ID          = 0xF2;
    static const int COMMAND_SET_REMOTE_MODE        = 0xF0;
    static const int COMMAND_SET_WRAP_MODE          = 0xEE;
    static const int COMMAND_RESET_WRAP_MODE        = 0xEC;
    static const int COMMAND_READ_DATA              = 0xEB;
    static const int COMMAND_SET_STREAM_MODE        = 0xEA;
    static const int COMMAND_STATUS_REQUEST         = 0xE9;
    static const int COMMAND_SET_RESOLUTION         = 0xE8;
    static const int COMMAND_SET_SCALING_2_TO_1     = 0xE7;
    static const int COMMAND_SET_SCALING_1_TO_1     = 0xE6;

    static const int STATUS_ACK                     = 0xFA;
    static const int STATUS_ERROR                   = 0x00;

    int read( );
    int read( const unsigned int& timeout );
    void write( int data );
    char m_dir_x;
    char m_dir_y;
    TYPE_BUTTON_STATUS m_status[ N_BUTTON ];
};


#endif /*MOUSE_H_*/
